
varying vec2 vUv;
attribute float imgIndex;
attribute float aScale;
varying float vImgIndex;
varying vec3 vColor;
uniform float uTime;
attribute vec3 color;
void main(){
    vec4 modelPosition = modelMatrix * vec4( position, 1.0 );

    // 使用顶点着色器设置顶点旋转角度 与 旋转动画
    // 获取顶点的角度
    float angle = atan(modelPosition.x,modelPosition.z);
    // 获取顶点到中心点的距离
    float distanceToCenter = length(modelPosition.xz);
    // 根据顶点到中心的距离，设置旋转偏移度数
    float angleOffset =1.0/distanceToCenter*uTime;

    angle+=angleOffset;

    modelPosition.x =cos(angle) * distanceToCenter;
    modelPosition.z =sin(angle) * distanceToCenter;


    vec4 viewPosition = viewMatrix * modelPosition;
    // 设置点位置
    gl_Position =  projectionMatrix * viewPosition;

    // 设置点大小
    // gl_PointSize = 50.0;
    // 设置点大小根据viewPosition的z坐标决定远离摄像机(相机位置与点的距离）
     gl_PointSize =200.0/-viewPosition.z*aScale;

    vUv = uv;
    vImgIndex = imgIndex;
    vColor = color;
}